﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utility;
using Utility.Json;
using Utility.Model;
using MsgCenter.Service.BLL;
using Hxj.Data;
using System.Data;
using MsgCenter.Service.Helper;

namespace MsgCenter.Service
{
    public class SyncInfoDataService
    {
        #region WebService 属性
        static Siva_DicType_WS.DicTypeWSImplService _dictypeWS;
        static Siva_DicType_WS.DicTypeWSImplService WS_DicType
        {
            get
            {
                if (_dictypeWS == null)
                {
                    _dictypeWS = new Siva_DicType_WS.DicTypeWSImplService();
                }
                return _dictypeWS;
            }
        }
        static Siva_Common_WS.CommonWSImplService _commonWS;
        static Siva_Common_WS.CommonWSImplService WS_Common
        {
            get
            {
                if (_commonWS == null)
                {
                    _commonWS = new Siva_Common_WS.CommonWSImplService();
                }
                return _commonWS;
            }
        }
        static Siva_UserInfo_WS.UserInfoWSImplService _userInfows;
        static Siva_UserInfo_WS.UserInfoWSImplService WS_UserInfo
        {
            get
            {
                if (_userInfows == null)
                {
                    _userInfows = new Siva_UserInfo_WS.UserInfoWSImplService();
                }
                return _userInfows;
            }
        }
        static Siva_OrgInfo_WS.OrgInfoWSImplService _orgInfows;
        static Siva_OrgInfo_WS.OrgInfoWSImplService WS_OrgInfo
        {
            get
            {
                if (_orgInfows == null)
                {
                    _orgInfows = new Siva_OrgInfo_WS.OrgInfoWSImplService();
                }
                return _orgInfows;
            }
        }
        #endregion
        /// <summary>
        /// 获取UIS系统中Ticket
        /// </summary>
        /// <param name="modelSyncInfo"></param>
        /// <returns></returns>
        private static string getServerTicket(TB_SyncInfo_Data modelSyncInfo)
        {
            string text = "";
            string serverTicket = WS_Common.getServerTicket(modelSyncInfo.userUid, modelSyncInfo.userPassword, modelSyncInfo.appCode, modelSyncInfo.appPassword, modelSyncInfo.url);
            Dictionary<string, object> dictionary = (Dictionary<string, object>)JsonHelper.JsonToObject(serverTicket);
            if (dictionary["success"].ToSafeString().ToEquals("true"))
            {
                dictionary = (Dictionary<string, object>)dictionary["data"];
                if (dictionary != null && dictionary.Count > 0)
                {
                    text = dictionary["tgtId"].ToSafeString();
                }
            }
            LogServiceHelper.WriteSyncDataLog("开始执行数据同步方法：getServerTicket：" + text + " \r\n  接收的Json数据格式： " + serverTicket);
            return text;
        }
        /// <summary>
        /// 根据UIS的Ticket来获取UIS服务器上的时间
        /// </summary>
        /// <param name="strTgtId"></param>
        /// <returns></returns>
        private static string getServerDateTime(string strTgtId)
        {
            string serverDateTime = WS_Common.getServerDateTime(strTgtId);
            object obj = JsonHelper.JsonToObject(serverDateTime);
            string text = "";
            Dictionary<string, object> dictionary = (Dictionary<string, object>)obj;
            if (dictionary["success"].ToSafeString().ToEquals("true"))
            {
                dictionary = (Dictionary<string, object>)dictionary["data"];
                if (dictionary != null && dictionary.Count > 0)
                {
                    text = dictionary["ServerTime"].ToSafeString();
                }
            }
            LogServiceHelper.WriteSyncDataLog("开始执行数据同步方法：getServerDateTime：" + text + " \r\n  接收的Json数据格式： " + serverDateTime);
            return text;
        }
        /// <summary>
        /// 数据同步
        /// </summary>
        public static void SyncDataALL()
        {
            try
            {
                LogServiceHelper.WriteSyncDataLog("开始执行数据同步方法：SyncDataALL");
                TB_SyncInfo_Data syncInfoData = MsgBLLService.CreateDataService().GetSyncInfoData();
                if (syncInfoData != null)
                {
                    string serverTicket = getServerTicket(syncInfoData);
                    if (syncInfoData.operationTime_Org.IsNullOrEmpty())
                    {
                        string serverDateTime = getServerDateTime(serverTicket);
                        if (SyncOrgs(serverTicket, serverDateTime))
                        {
                            MsgBLLService.CreateDataService().UpdateSyncInfoOperationTime("Org", serverDateTime.ToSafeDateTime(), TB_SyncInfo_Data._.userUid == syncInfoData.userUid);
                        }
                    }
                    else if (SyncOrgs(serverTicket, syncInfoData.operationTime_Org))
                    {
                        MsgBLLService.CreateDataService().UpdateSyncInfoOperationTime("Org", DateTime.Now, TB_SyncInfo_Data._.userUid == syncInfoData.userUid);
                    }
                    if (syncInfoData.operationTime_User.IsNullOrEmpty())
                    {
                        string serverDateTime2 = getServerDateTime(serverTicket);
                        if (SyncUser(serverTicket, ""))
                        {
                            MsgBLLService.CreateDataService().UpdateSyncInfoOperationTime("User", serverDateTime2.ToSafeDateTime(), TB_SyncInfo_Data._.userUid == syncInfoData.userUid);
                        }
                    }
                    else if (SyncUser(serverTicket, syncInfoData.operationTime_User))
                    {
                        MsgBLLService.CreateDataService().UpdateSyncInfoOperationTime("User", DateTime.Now, TB_SyncInfo_Data._.userUid == syncInfoData.userUid);
                    }

                    if (syncInfoData.operationTime_Dic.IsNullOrEmpty())
                    {
                        string serverDateTime2 = getServerDateTime(serverTicket);
                        if (SyncDicType(serverTicket, ""))
                        {
                            MsgBLLService.CreateDataService().UpdateSyncInfoOperationTime("Dic", serverDateTime2.ToSafeDateTime(), TB_SyncInfo_Data._.userUid == syncInfoData.userUid);
                        }
                    }
                    else if (SyncDicType(serverTicket, syncInfoData.operationTime_Dic))
                    {
                        MsgBLLService.CreateDataService().UpdateSyncInfoOperationTime("Dic", DateTime.Now, TB_SyncInfo_Data._.userUid == syncInfoData.userUid);
                    }
                }
            }
            catch (Exception se)
            {
                LogServiceHelper.WriteSyncDataError("执行数据同步SyncDataALL出现错误", se);
            }
        }
        /// <summary>
        /// 测试，
        /// </summary>
        public static void SyncDataALLTest()
        {
            try
            {
                LogServiceHelper.WriteSyncDataLog("开始执行数据同步方法：SyncDataALL");
                TB_SyncInfo_Data syncInfoData = MsgBLLService.CreateDataService().GetSyncInfoData();
                if (syncInfoData != null)
                {
                    string serverTicket = getServerTicket(syncInfoData);
                    if (syncInfoData.operationTime_Dic.IsNullOrEmpty())
                    {
                        string serverDateTime2 = getServerDateTime(serverTicket);
                        if (SyncDicType(serverTicket, ""))
                        {
                            MsgBLLService.CreateDataService().UpdateSyncInfoOperationTime("Dic", serverDateTime2.ToSafeDateTime(), TB_SyncInfo_Data._.userUid == syncInfoData.userUid);
                        }
                    }
                    else if (SyncDicType(serverTicket, syncInfoData.operationTime_Dic))
                    {
                        MsgBLLService.CreateDataService().UpdateSyncInfoOperationTime("Dic", DateTime.Now, TB_SyncInfo_Data._.userUid == syncInfoData.userUid);
                    }
                }
            }
            catch (Exception se)
            {
                LogServiceHelper.WriteSyncDataError("执行数据同步SyncDataALL出现错误", se);
            }
        }
        /// <summary>
        /// 根据UIS的Ticket和服务器时间来同步UIS字典类别
        /// </summary>
        /// <param name="strTgtId"></param>
        /// <param name="strOperationTime"></param>
        /// <returns></returns>
        private static bool SyncDicType(string strTgtId, string strOperationTime)
        {
            try
            {
                string text = WS_DicType.queryDicType(strTgtId);
                LogServiceHelper.WriteSyncDataLog("开始执行数据同步方法：SyncDicType:" + text);
                Dictionary<string, object> dictionary = (Dictionary<string, object>)JsonHelper.JsonToObject(text);
                if (dictionary["success"].ToSafeString().ToEquals("true"))
                {
                    dictionary = (Dictionary<string, object>)dictionary["data"];
                    if (dictionary != null && dictionary.Count > 0)
                    {
                        object[] array = (object[])dictionary["map"];
                        if (array.Length != 0)
                        {
                            string dicName = string.Empty;
                            string dicCode = string.Empty;
                            Dictionary<string, object> dictionary2 = null;
                            foreach (object obj in array)
                            {
                                dicName = string.Empty;
                                dicCode = string.Empty;
                                dictionary2 = (Dictionary<string, object>)obj;
                                dicName = dictionary2["dicName"].ToSafeString().Trim();
                                dicCode = dictionary2["dicCode"].ToSafeString().Trim();
                                Sys_Dic dicModel = MsgBLLService.CreateDataService().GetDicModel(Sys_Dic._.DicID == dicCode);
                                if (dicModel == null)
                                {
                                    dicModel = new Sys_Dic();
                                    dicModel.ParentDicID = Guid.Empty.ToSafeString();
                                    dicModel.Sort = MsgBLLService.CreateDataService().GetDicMaxSort(dicModel.ParentDicID);
                                    dicModel.CreateUser = "system_sync";
                                }
                                dicModel.IsDelete = false;
                                dicModel.DicID = dicCode;
                                dicModel.DicName = dicName;
                                dicModel.DicDes = dicName;
                                MsgBLLService.CreateDataService().Save(dicModel);
                                SyncDicCode(strTgtId, dicCode);
                            }
                        }
                    }
                }
                return true;
            }
            catch (Exception se)
            {
                LogServiceHelper.WriteSyncDataError("同步SyncDicType方法出现错误：", se);
                return true;
            }
        }
        /// <summary>
        /// 根据UIS的Ticket和类别ID来获取字典项值
        /// </summary>
        /// <param name="strTgtId"></param>
        /// <param name="dicParentCode"></param>
        private static void SyncDicCode(string strTgtId, string dicParentCode)
        {
            try
            {
                string text = WS_DicType.queryDicTreeByType(strTgtId, dicParentCode);
                LogServiceHelper.WriteSyncDataLog("开始执行数据同步方法：SyncDicCode:" + text);
                Dictionary<string, object> dictionary = (Dictionary<string, object>)JsonHelper.JsonToObject(text);
                if (dictionary["success"].ToSafeString().ToEquals("true"))
                {
                    dictionary = (Dictionary<string, object>)dictionary["data"];
                    if (dictionary != null && dictionary.Count > 0)
                    {
                        object[] array = (object[])dictionary["map"];
                        if (array.Length != 0)
                        {
                            string dicName = string.Empty;
                            string dicCode = string.Empty;
                            Dictionary<string, object> dictionary2 = null;
                            foreach (object obj in array)
                            {
                                dicName = string.Empty;
                                dicCode = string.Empty;
                                dictionary2 = (Dictionary<string, object>)obj;
                                dicName = dictionary2["dicName"].ToSafeString().Trim();
                                dicCode = dictionary2["dicCode"].ToSafeString().Trim();
                                Sys_Dic dicModel = MsgBLLService.CreateDataService().GetDicModel(Sys_Dic._.DicID == dicCode);
                                if (dicModel == null)
                                {
                                    dicModel = new Sys_Dic();
                                    dicModel.ParentDicID = dicParentCode;
                                    dicModel.Sort = MsgBLLService.CreateDataService().GetDicMaxSort(dicModel.ParentDicID);
                                    dicModel.CreateUser = "system_sync";
                                }
                                dicModel.IsDelete = false;
                                dicModel.DicID = dicCode;
                                dicModel.DicName = dicName;
                                dicModel.DicDes = dicName;
                                MsgBLLService.CreateDataService().Save(dicModel);
                            }
                        }
                    }
                }
            }
            catch (Exception se)
            {
                LogServiceHelper.WriteSyncDataError("同步SyncDicCode方法出现错误：", se);
            }
        }

        /// <summary>
        /// 将数组转换成DataTable
        /// </summary>
        /// <param name="objs"></param>
        /// <returns></returns>
        private static DataTable DicToTable(object[] objs)
        {
            DataTable dataTable = new DataTable();
            for (int i = 0; i < objs.Length; i++)
            {
                Dictionary<string, object> dictionary = (Dictionary<string, object>)objs[i];
                if (dataTable.Columns.Count == 0)
                {
                    foreach (string key in dictionary.Keys)
                    {
                        dataTable.Columns.Add(key, typeof(string));
                    }
                }
                DataRow dataRow = dataTable.NewRow();
                foreach (KeyValuePair<string, object> item in dictionary)
                {
                    dataRow[item.Key] = item.Value;
                }
                dataTable.Rows.Add(dataRow);
            }
            return dataTable;
        }
        /// <summary>
        /// 根据DataTable数据同步组织机构，写入数据表
        /// </summary>
        /// <param name="dt"></param>
        private static void SyncOrgs_dg(DataTable dt)
        {
            Sys_Dept sys_Dept = null;
            Sys_Dept sys_Dept2 = null;
            foreach (DataRow row in dt.Rows)
            {
                string text = row["orgCode"].ToSafeString();
                string deptName = row["orgName"].ToSafeString();
                string value = row["parentOrgCode"].ToSafeString();
                string value2 = row["orgSequence"].ToSafeString();
                row["operationStatus"].ToSafeString();
                sys_Dept = MsgBLLService.CreateDataService().GetDeptModel(Sys_Dept._.ID == text);
                if (sys_Dept == null)
                {
                    sys_Dept = new Sys_Dept();
                    sys_Dept.CreateDate = DateTime.Now;
                    sys_Dept.CreateUser = "admin";
                    sys_Dept.ID = text;
                    if (text.ToEquals("siva"))
                    {
                        sys_Dept.ParentID = "0";
                        if (MsgBLLService.CreateDataService().GetMaxDeptIDByFatherID(sys_Dept.ParentID).Length == 0)
                        {
                            sys_Dept.DeptID = "00001";
                        }
                        else
                        {
                            sys_Dept.DeptID = MsgBLLService.CreateDataService().GetMaxDeptIDByFather(sys_Dept.ParentID);
                        }
                    }
                    else
                    {
                        sys_Dept2 = MsgBLLService.CreateDataService().GetDeptModel(Sys_Dept._.ID == value);
                        if (sys_Dept2 != null)
                        {
                            sys_Dept.ParentID = sys_Dept2.DeptID;
                        }
                        sys_Dept.DeptID = MsgBLLService.CreateDataService().GetMaxDeptIDByFather(sys_Dept.ParentID);
                    }
                }
                sys_Dept.DeptCode = text;
                sys_Dept.DeptName = deptName;
                sys_Dept.Sort = value2.ToSafeInt();
                MsgBLLService.CreateDataService().Save(sys_Dept);
            }
        }
        /// <summary>
        /// 将DataTable和上级节点转换成Sys_Dept写入数据表
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="strParentCode"></param>
        private static void SyncOrgs_dg(DataTable dt, string strParentCode)
        {
            Sys_Dept sys_Dept = null;
            Sys_Dept sys_Dept2 = null;
            DataRow[] array = dt.Select(" parentOrgCode='" + strParentCode + "' ", " orgSequence asc ");
            foreach (DataRow dataRow in array)
            {
                string text = dataRow["orgCode"].ToSafeString();
                string deptName = dataRow["orgName"].ToSafeString();
                string value = dataRow["parentOrgCode"].ToSafeString();
                string value2 = dataRow["orgSequence"].ToSafeString();
                dataRow["operationStatus"].ToSafeString();
                sys_Dept = MsgBLLService.CreateDataService().GetDeptModel(Sys_Dept._.ID == text);
                if (sys_Dept == null)
                {
                    sys_Dept = new Sys_Dept();
                    sys_Dept.CreateDate = DateTime.Now;
                    sys_Dept.CreateUser = "admin";
                    sys_Dept.ID = text;
                    if (text.ToEquals("siva"))
                    {
                        sys_Dept.ParentID = "0";
                        if (MsgBLLService.CreateDataService().GetMaxDeptIDByFatherID(sys_Dept.ParentID).Length == 0)
                        {
                            sys_Dept.DeptID = "00001";
                        }
                        else
                        {
                            sys_Dept.DeptID = MsgBLLService.CreateDataService().GetMaxDeptIDByFather(sys_Dept.ParentID);
                        }
                    }
                    else
                    {
                        sys_Dept2 = MsgBLLService.CreateDataService().GetDeptModel(Sys_Dept._.ID == value);
                        if (sys_Dept2 != null)
                        {
                            sys_Dept.ParentID = sys_Dept2.DeptID;
                        }
                        sys_Dept.DeptID = MsgBLLService.CreateDataService().GetMaxDeptIDByFather(sys_Dept.ParentID);
                    }
                }
                sys_Dept.DeptCode = text;
                sys_Dept.DeptName = deptName;
                sys_Dept.Sort = value2.ToSafeInt();
                MsgBLLService.CreateDataService().Save(sys_Dept);
                SyncOrgs_dg(dt, dataRow["orgCode"].ToSafeString());
            }
        }
        /// <summary>
        /// 根据UIS的Ticket和时间同步组织机构数据
        /// </summary>
        /// <param name="strTgtId"></param>
        /// <param name="strOperationTime"></param>
        /// <returns></returns>
        private static bool SyncOrgs(string strTgtId, string strOperationTime)
        {
            try
            {
                string text = WS_OrgInfo.syncOrgs(strTgtId, strOperationTime.ToSafeDateTime().DateTimeToyyyy_MM_dd_HH_mm_ss());
                LogServiceHelper.WriteSyncDataLog("开始执行数据同步方法：SyncOrgs:" + text);
                Dictionary<string, object> dictionary = (Dictionary<string, object>)JsonHelper.JsonToObject(text);
                if (dictionary["success"].ToSafeString().ToEquals("true"))
                {
                    dictionary = (Dictionary<string, object>)dictionary["data"];
                    if (dictionary != null && dictionary.Count > 0)
                    {
                        object[] array = (object[])dictionary["map"];
                        if (array.Length != 0)
                        {
                            using (DataTable dataTable = DicToTable(array))
                            {
                                if (dataTable.Rows.Count <= 0)
                                {
                                    return false;
                                }
                                SyncOrgs_dg(dataTable);
                                return true;
                            }
                        }
                    }
                }
                return false;
            }
            catch (Exception se)
            {
                LogServiceHelper.WriteSyncDataError("同步SyncOrgs方法出现错误：", se);
                return true;
            }
        }

        private static string strPassword = "";
        private static string Password
        {
            get
            {
                if (strPassword == "")
                {
                    strPassword = "111111".ToSafeEncrypt();
                }
                return strPassword;
            }
        }
        /// <summary>
        /// 根据UIS的Ticket和时间来同步用户数据
        /// </summary>
        /// <param name="strTgtId"></param>
        /// <param name="strOperationTime"></param>
        /// <returns></returns>
        private static bool SyncUser(string strTgtId, string strOperationTime)
        {
            try
            {
                string text = WS_UserInfo.syncUser(strTgtId, strOperationTime.ToSafeDateTime().DateTimeToyyyy_MM_dd_HH_mm_ss());
                LogServiceHelper.WriteSyncDataLog("开始执行数据同步方法：SyncUser:" + text);
                Dictionary<string, object> dictionary = (Dictionary<string, object>)JsonHelper.JsonToObject(text);
                if (dictionary["success"].ToSafeString().ToEquals("true"))
                {
                    dictionary = (Dictionary<string, object>)dictionary["data"];
                    if (dictionary != null && dictionary.Count > 0)
                    {
                        object[] array = (object[])dictionary["map"];
                        if (array.Length != 0)
                        {
                            string empty = string.Empty;
                            string empty2 = string.Empty;
                            string empty9 = string.Empty;
                            string empty3 = string.Empty;
                            string empty4 = string.Empty;
                            string empty5 = string.Empty;
                            string empty6 = string.Empty;
                            string empty7 = string.Empty;
                            string empty8 = string.Empty;
                            Sys_User sys_User = null;
                            Sys_UserRoles sys_UserRoles = null;
                            Dictionary<string, object> dictionary2 = null;
                            object[] array2 = array;
                            foreach (object obj in array2)
                            {
                                sys_UserRoles = null;
                                sys_User = null;
                                empty8 = string.Empty;
                                empty = string.Empty;
                                empty2 = string.Empty;
                                string empty10 = string.Empty;
                                empty3 = string.Empty;
                                empty4 = string.Empty;
                                empty5 = string.Empty;
                                empty6 = string.Empty;
                                empty7 = string.Empty;
                                dictionary2 = (Dictionary<string, object>)obj;
                                if (empty8.Length > 0)
                                {
                                    LogServiceHelper.WriteSyncDataError("同步SyncUser方法出现错误:" + empty8);
                                }
                                else
                                {
                                    empty6 = dictionary2["orgCode"].ToSafeString().Trim();
                                    empty = dictionary2["userUid"].ToSafeString().Trim();
                                    empty2 = dictionary2["userName"].ToSafeString().Trim();
                                    //if (dictionary2.ContainsKey("userPasswd"))
                                    //{
                                    //    dictionary2["userPasswd"].ToSafeString().Trim();
                                    //}
                                    if (dictionary2.ContainsKey("userEmail"))
                                    {
                                        empty3 = dictionary2["userEmail"].ToSafeString().Trim();
                                    }
                                    if (dictionary2.ContainsKey("userLocked"))
                                    {
                                        empty4 = dictionary2["userLocked"].ToSafeString().Trim();
                                    }
                                    if (dictionary2.ContainsKey("userMobilePhone"))
                                    {
                                        empty5 = dictionary2["userMobilePhone"].ToSafeString().Trim();
                                    }
                                    if (dictionary2.ContainsKey("userType"))
                                    {
                                        empty7 = dictionary2["userType"].ToSafeString().Trim();
                                    }
                                    sys_User = MsgBLLService.CreateDataService().GetUserModel(Sys_User._.UserName == empty);
                                    if (sys_User == null)
                                    {
                                        sys_User = new Sys_User();
                                        sys_User.IsAdmin = false;
                                        sys_UserRoles = new Sys_UserRoles();
                                        sys_UserRoles.UserID = sys_User.UserID;
                                        sys_UserRoles.RoleID = AppConfigHelper.strMessageCenter_RoleID;
                                    }
                                    if (empty.ToEquals(AppConfigHelper.strAdmin_UserName))
                                    {
                                        sys_User.IsAdmin = true;
                                    }
                                    sys_User.UserTypeName = empty7;
                                    sys_User.Name = empty2;
                                    sys_User.Code = empty;
                                    sys_User.CreateUser = "admin";
                                    sys_User.DeptGuID = empty6;
                                    sys_User.Email = empty3;
                                    if (empty4.Equals("1"))
                                    {
                                        sys_User.IsDelete = true;
                                    }
                                    else
                                    {
                                        sys_User.IsDelete = false;
                                    }
                                    sys_User.Mobile = empty5;
                                    sys_User.Password = Password;
                                    sys_User.UserName = empty;
                                    MsgBLLService.CreateDataService().Save(sys_User, sys_UserRoles);
                                }
                            }
                            return true;
                        }
                    }
                }
                return false;
            }
            catch (Exception se)
            {
                LogServiceHelper.WriteSyncDataError("同步SyncUser方法出现错误：", se);
                return true;
            }
        }

        private static string IsDicNull(Dictionary<string, object> dicObj)
        {
            string text = string.Empty;
            if (!dicObj.ContainsKey("userUid"))
            {
                text += "userUid 不在json中";
            }
            else if (dicObj["userUid"].ToSafeString().Trim().Length == 0)
            {
                text += "userUid 不在json中或为空";
            }
            if (!dicObj.ContainsKey("userName"))
            {
                text += "userName 不在json中";
            }
            else if (dicObj["userName"].ToSafeString().Trim().Length == 0)
            {
                text += "userName 不在json中或为空";
            }
            if (!dicObj.ContainsKey("userPasswd"))
            {
                text += "userPasswd 不在json中";
            }
            else if (dicObj["userPasswd"].ToSafeString().Trim().Length == 0)
            {
                text += "userPasswd 不在json中或为空";
            }
            if (!dicObj.ContainsKey("userEmail"))
            {
                text += "userEmail 不在json中";
            }
            else if (dicObj["userEmail"].ToSafeString().Trim().Length == 0)
            {
                text += "userEmail 不在json中或为空";
            }
            if (!dicObj.ContainsKey("userLocked"))
            {
                text += "userLocked 不在json中";
            }
            else if (dicObj["userLocked"].ToSafeString().Trim().Length == 0)
            {
                text += "userLocked 不在json中或为空";
            }
            if (!dicObj.ContainsKey("userMobilePhone"))
            {
                text += "userMobilePhone 不在json中";
            }
            else if (dicObj["userMobilePhone"].ToSafeString().Trim().Length == 0)
            {
                text += "userMobilePhone 不在json中或为空";
            }
            if (!dicObj.ContainsKey("orgCode"))
            {
                text += "orgCode 不在json中";
            }
            else if (dicObj["orgCode"].ToSafeString().Trim().Length == 0)
            {
                text += "orgCode 不在json中或为空";
            }
            return text;
        }
    }
}